# Maintainer: Jelle van der Waa <jelle@archlinux.org>
# Contributor: Eli Schwartz <eschwartz93@gmail.com>

_pkgname=unrardll
pkgname=python-unrardll
pkgver=0.1.5
pkgrel=4
pkgdesc="Python wrapper for UnRAR DLL"
arch=('loong64' 'x86_64')
url="https://github.com/kovidgoyal/${_pkgname}"
license=('BSD')
depends=('libunrar' 'python')
makedepends=('python-setuptools')
source=("https://pypi.io/packages/source/${_pkgname:0:1}/${_pkgname}/${_pkgname}-${pkgver}.tar.gz"{,.asc})
sha256sums=('8bebb480b96cd49d4290d814914f39cff75cf0fa0514c4790bb32b1757227c78'
            'SKIP')
b2sums=('601bd79699b9bcf3d153314ac55b2263945af3795fd6a8dbdafe05950d5e548fecab03cdcb1449bda254548180c955cabe75a51ebaf2a35f10e69dc85c1430a8'
        'SKIP')
validpgpkeys=('3CE1780F78DD88DF45194FD706BC317B515ACE7C')

build() {
  cd "${srcdir}/${_pkgname}-${pkgver}"

  python setup.py build
}

check() {
  cd "${srcdir}/${_pkgname}-${pkgver}"

  local python_version=$(python -c 'import sys; print("".join(map(str, sys.version_info[:2])))')
  PYTHONPATH="$PWD/build/lib.linux-$CARCH-cpython-${python_version}" python -m unittest test/basic.py
}

package() {
  cd "${srcdir}/${_pkgname}-${pkgver}"

  python setup.py install --root="${pkgdir}" --optimize=1 --skip-build
  install -Dm644 LICENSE "${pkgdir}/usr/share/licenses/${pkgname}/LICENSE"
}
